#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

bool is_prime(int n) {
    bool F = true;
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0) {
            F = false;
            break;
        }
    }
    return F;
}

int main() {
    string number = "";
    string x;
    getline(cin, x);
    vector<string> word;
    size_t pos = 0;
    while ((pos = x.find(" ")) != string::npos) {
        word.push_back(x.substr(0, pos));
        x.erase(0, pos + 1);
    }
    word.push_back(x);

    for (size_t i = 0; i < word.size(); i++) {
        if (word[i] == "zero") number += '0';
        else if (word[i] == "one") number += '1';
        else if (word[i] == "two") number += '2';
        else if (word[i] == "three") number += '3';
        else if (word[i] == "four") number += '4';
        else if (word[i] == "five") number += '5';
        else if (word[i] == "six") number += '6';
        else if (word[i] == "seven") number += '7';
        else if (word[i] == "eight") number += '8';
        else if (word[i] == "nine") number += '9';
    }

    int num;
    if (!number.empty())
        num = stoi(number);
    else
        num = 0;

    vector<int> spis;
    for (int i = 100; i <= 999; i++) {
        if (is_prime(i))
            spis.push_back(i);
    }

    if (num < 100  num > 999  word.size() != 3) {
        cout << "Wrong input" << endl;
    } else {
        int min_r = 1000;
        int min_g;
        for (size_t i = 0; i < spis.size(); i++) {
            if (abs(num - spis[i]) <= min_r) {
                min_r = abs(num - spis[i]);
                min_g = i;
            }
        }
        cout << spis[min_g] << endl;
    }

    return 0;
}
